<template>
	<view class="container">
		<view class="addInfohead">
			<view>请完善信息</view>
			<view>方便我们您提供服务</view>
		</view>
		<view class="addInfocon">
			<view class="addInfoconipt">
				<input type="text" v-model="name" placeholder-style="color:#ffffff;opacity:0.6" placeholder="请输入姓名" />
				<view class="addInfoconicon" @click="clearvalue(0)">
					<image src="../../static/ic_del.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="addInfoconipt">
				<input type="number" v-model="num" placeholder-style="color:#ffffff;opacity:0.6" placeholder="请输入手机号" />
				<view class="addInfoconicon" @click="clearvalue(1)">
					<image src="../../static/ic_del.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="addInfoconipt">
				<input type="idcard" v-model="IDcard" placeholder-style="color:#ffffff;opacity:0.6" placeholder="请输入身份证号" />
				<view class="addInfoconicon" @click="clearvalue(2)">
					<image src="../../static/ic_del.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<view class="addInfocom otherop" @click="binding">
			绑定
		</view>
	</view>
</template>

<script>
	import app from '../../App.vue'
	export default {
		data() {
			return {
				name:'',
				num:'',
				IDcard:''
			}
		},
		onShow() {
			
		},
		methods: {
			binding(){					//绑定
				let that = this,
				data = {
					name:that.name,
					mobile:that.num,
					id_no:that.IDcard
				}
				app.post('api/user/bind',data).then(res=>{
					if(res.code == 1){
						uni.showLoading({
							title:'加载中',
							success() {
								setTimeout(function(){
									uni.hideLoading()
									uni.navigateTo({
										url:'/pages/index/index'
									})
								},1300)
							}
						})
					}if(res.code == 0){
						uni.showToast({
							title:res.msg,
							icon:'none',
							mark:true
						})
					}
				}).catch(err=>{
					uni.showToast({
						title:res.msg,
						icon:'none',
						mark:true
					})
				})
			},
			clearvalue(val){			//清空input
				let that = this
				if(val == 0){
					that.name = ''
				}else if(val == 1){
					that.num = ''
				}else if(val == 2){
					that.IDcard = ''
				}
			}
			
		}
	}
</script>

<style>
	@import url("../../common/addInfo.css");
</style>
